home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / Hierarchical Lists / Libs / CTwistDownListBox.h < prev   
Encoding:
Text File  |  1995-10-24  |  3.1 KB  |  98 lines  |  [TEXT/MMCC]

  1. // ===========================================================================
  2. //    LHierarchicalListBox.h            ©1994 Jan Bruyndonckx All rights reserved.
  3. //    v1.0 18/6/94
  4. //
  5. //    A hierarchical listbox subclass.  The listbox contains only string data.
  6. // ===========================================================================
  7.  
  8. #pragma once
  9.  
  10. #include "CCustomListBox.h"
  11.  
  12. //----------------------------------------------------------------------------
  13.  
  14. typedef enum {
  15.     kHasSubList       = 0x01,            // item contains sub-items (eg. folder)
  16.     kIsOpened          = 0x02,            // the item is opened
  17.     kDrawFilled       = 0x04,            // draw the triangle filled
  18.     kDrawIntermediate = 0x08            // draw intermediate state
  19. } TwistDownFlags ;
  20.  
  21. #pragma options align=mac68k
  22.  
  23. #define TWIST_DOWN_HEAD                                \
  24.     Byte    indent ;    /* indentation level    */    \
  25.     Byte    flags ;        /* display flags        */
  26.  
  27. typedef struct {
  28.     TWIST_DOWN_HEAD
  29. } TwistDownHeader ;
  30.  
  31. typedef struct {
  32.     TWIST_DOWN_HEAD    
  33.     Byte    data[2] ;    // variable length of data (default=P-String)
  34. } TwistDownRec, *TwistDownRecPtr ;
  35.  
  36. #pragma options align=reset
  37.  
  38. #define TwistDownRecSize     (sizeof(TwistDownHeader))    // don't count the variable 'data' field
  39.  
  40. //----------------------------------------------------------------------------
  41.  
  42. class CTwistDownListBox : public CCustomListBox {
  43.  
  44.   public:
  45.       enum {
  46.           classID = 'hlst'
  47.       } ;
  48.         
  49.     static CTwistDownListBox*    CreateFromStream(LStream *inStream);
  50.  
  51.     CTwistDownListBox () ;
  52.     CTwistDownListBox (const SPaneInfo &inPaneInfo,
  53.                         Boolean inHasHorizScroll, Boolean inHasVertScroll,
  54.                         Boolean inHasGrow, Boolean inHasFocusBox,
  55.                         MessageT inDoubleClickMessage, Int16 inTextTraitsID,
  56.                         LCommander *inSuper);
  57.     CTwistDownListBox (const CTwistDownListBox &inOriginal);
  58.     CTwistDownListBox (LStream *inStream);
  59.  
  60.     virtual StringPtr    GetDescriptor(Str255 outDescriptor) const;
  61.     virtual void        SetDescriptor(ConstStr255Param inDescriptor);
  62.     virtual void        FullyExpand (const unsigned short inMaxDepth = 0xFFFF) ;
  63.  
  64.     void                 MouseInfo (Point theMouse, Boolean *inButtonArea, Cell *theCell) ;
  65.     
  66.   protected:
  67.       short    triangleWidth ;            // width of the triangle area
  68.       
  69.     virtual void    ClickSelf(const SMouseDownEvent &inMouseDown);                                // override LListBox
  70.     virtual void    ResizeFrameBy (Int16 inWidthDelta, Int16 inHeightDelta, Boolean inRefresh);    // override LListBox
  71.  
  72.     virtual void    DrawElementSelf (const Rect *lRect, 
  73.                                      const void *lElement,
  74.                                      const short lDataLen) ;
  75.     virtual void    DrawTwistedElement (const Rect *lRect,
  76.                                         const TwistDownRecPtr twistElement,
  77.                                         const short lDataLen) ;
  78.  
  79.     virtual void    CollapseElement (const Cell theCell) ;
  80.     virtual void    ExpandElement (const Cell theCell) ;
  81.     
  82.     virtual void    ListLimitReached (void) ;
  83.  
  84.     typedef enum {                        // Misc. constants
  85.         kTriangleOutsideGap    = 1,            // From margin to button
  86.         kTriangleInsideGap    = 3,            // From button to text
  87.         kScrollBarWidth        = 16,            // width of right scroll bar
  88.         kAnimationDelay        = 3,            // the time to show the intermediate button
  89.         kIndentOffset        = 16            // to offset each indentation level by
  90.     } ;
  91.  
  92.   private:
  93.       void            init (void) ;
  94.       
  95.       static    PolyHandle    sClosedPoly,
  96.                           sOpenedPoly,
  97.                           sIntermediatePoly ;
  98. } ;